import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsDefined, IsInt, IsNotEmpty } from 'class-validator';
import { PageDto } from 'src/common/dto/dto';
import { FindOperator } from 'typeorm';

/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-02-17 13:58:56
 */
export class CreateAdminUserDto { }
export class GetAdminUserPage extends PageDto {
  @ApiPropertyOptional({
    type: Number,
    name: 'id',
    description: 'id',
  })
  public readonly id: number;
  @ApiPropertyOptional({
    type: String,
    name: 'username',
    description: '用户名',
  })
  public readonly username: FindOperator<string>;
  @ApiPropertyOptional({
    type: String,
    name: 'account',
    description: '账号',
  })
  public readonly account: FindOperator<string>;
  @ApiPropertyOptional({
    type: String,
    name: 'isDel',
    description: '是否启用：0否，1是',
    enum: [0, 1],
  })
  public readonly isDel: string;
}
export class ValidateUserDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  @ApiProperty({
    type: String,
    name: 'username',
    description: '用户名',
  })
  public readonly username: string;

  @IsNotEmpty({ message: '密码不能为空' })
  @ApiProperty({
    type: String,
    name: 'password',
    description: '密码',
  })
  public readonly password: string;
}
export class RegisterUserDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  @ApiProperty({
    type: String,
    name: 'username',
    description: '用户名',
  })
  public readonly username: string;

  @IsNotEmpty({ message: '用户账号不能为空' })
  @ApiProperty({
    type: String,
    name: 'account',
    description: '用户账号',
  })
  public readonly account: string;

  @IsNotEmpty({ message: '密码不能为空' })
  @ApiProperty({
    type: String,
    name: 'password',
    description: '密码',
  })
  public readonly password: string;

  @ApiPropertyOptional({
    type: String,
    name: 'isDel',
    description: '是否启用：0否，1是',
    enum: [0, 1],
  })
  public readonly isDel: string;
  @ApiPropertyOptional({
    type: String,
    name: 'avatar',
    description: '用户头像',
  })
  public readonly avatar: string;
}
export class UpdatePassWordDto {
  @IsNotEmpty({ message: '用户ID不能为空' })
  @ApiProperty({
    type: Number,
    name: 'userId',
    description: 'userId',
  })
  public readonly userId: number;

  @IsNotEmpty({ message: '登录密码不能为空' })
  @ApiProperty({
    type: String,
    name: 'old_password',
    description: '登录密码',
  })
  public readonly old_password: string;

  @IsNotEmpty({ message: '新密码不能为空' })
  @ApiProperty({
    type: String,
    name: 'new_password',
    description: '新密码',
  })
  public readonly new_password: string;
}
// 删除
export class DelteIdDto {
  @IsNotEmpty({ message: 'id不能为空' })
  @IsInt({ message: 'id不是整数' })
  @IsDefined()
  @ApiProperty({
    type: Number,
    name: 'id',
    description: 'id',
  })
  public readonly id: number;
}
export class GetUserInfoDto {
  @ApiPropertyOptional({
    type: Number,
    name: 'id',
    description: 'id',
  })
  public readonly id?: number;

  @ApiPropertyOptional({
    type: String,
    name: 'account',
    description: '用户账号',
  })
  public readonly account?: string;
}
export class AdminUserBindRoleDto {
  @IsNotEmpty({ message: '用户ID不能为空' })
  @ApiProperty({
    type: Number,
    name: 'userId',
    description: 'userId',
  })
  public readonly userId: number;
  @IsNotEmpty({ message: '角色ID不能为空' })
  @ApiProperty({
    type: Number,
    name: 'roleId',
    description: '角色ID不能为空',
  })
  public readonly roleId: number;
}
export class UpdateAdminUserDto {
  @IsNotEmpty({ message: '用户ID不能为空' })
  @ApiProperty({
    type: Number,
    name: 'userId',
    description: 'userId',
  })
  public readonly userId: number;
  @ApiPropertyOptional({
    type: String,
    name: 'isDel',
    description: '是否启用：0否，1是',
    enum: [0, 1],
  })
  public readonly isDel: string;
  @ApiPropertyOptional({
    type: String,
    name: 'avatar',
    description: '用户头像',
  })
  public readonly avatar: string;

  @IsNotEmpty({ message: '用户名不能为空' })
  @ApiProperty({
    type: String,
    name: 'username',
    description: '用户名',
  })
  public readonly username: string;

}
